package com.shundr.auth.user.http;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.os.Handler;
import android.os.Message;

import com.shundr.auth.common.model.VersionInfo;
import com.shundr.auth.frame.constant.LCommands;
import com.shundr.auth.frame.constant.LContext;
import com.shundr.auth.frame.http.HttpResult;
import com.shundr.auth.frame.http.LHttpRequest;
import com.shundr.auth.frame.http.LHttpRequest.RequestCompleteListener;
import com.shundr.auth.frame.util.EncryptionUtils;
import com.shundr.auth.frame.util.IpUtils;
import com.shundr.auth.frame.util.JsonUtil;
import com.shundr.auth.frame.util.LLogger;
import com.shundr.auth.user.model.ChannelInfo;
import com.shundr.auth.user.model.StaffInfo;
import com.shundr.auth.user.model.UserInfo;

public class UserRequest extends LHttpRequest implements
		RequestCompleteListener {

	public static final int ADMIN_LOGIN_SUCCESSED = 100;// 管理员登录成功
	public static final int LOGIN_SUCCESSED = 101;// 登录成功
	public static final int CHECK_PHONE_SUCCESSED = 2;// 检测手机号成功
	public static final int GET_AUTH_CODE_SUCCESSED = 3;// 获取验证码成功
	public static final int CHECK_CAPTCHA_SUCCESSED = 4;// 验证码成功
	public static final int REGISTER_SUCCESSED = 5;// 注册成功
	public static final int COMPANY_AUTH_COMMIT_SUCCESSED = 6;// 货主提交认证信息成功
	public static final int SUBMIT_AUTH_SUCCESSED = 7;// 提交认证成功
	public static final int GET_AUTH_LIST_SUCCESSED = 8;// 获取企业认证列表成功
	public static final int GET_AUTH_DETAIL_SUCCESSED = 9;// 获取企业认证详情成功
	public static final int AUTH_CONFIRM_SUCCESSED = 10;// 认证确认成功
	public static final int DRIVER_AUTH_COMMIT_SUCCESSED = 11;// 提交司机认证信息成功
	public static final int GET_AUTH_DRIVER_LIST_SUCCESSED = 12;// 获取企业认证列表成功
	public static final int GET_AUTH_DRIVER_DETAIL_SUCCESSED = 13;// 获取司机认证详情成功
	public static final int AUTH_DRIVER_CONFIRM_SUCCESSED = 14;// 认证确认成功
	public static final int OWNNER_AUTH_COMMIT_SUCCESSED = 15;// 提交司机认证信息成功
	public static final int GET_AUTH_OWNNER_LIST_SUCCESSED = 16;// 获取个人认证列表成功
	public static final int GET_AUTH_OWNNER_DETAIL_SUCCESSED = 17;// 获取个人认证详情成功
	public static final int AUTH_OWNNER_CONFIRM_SUCCESSED = 18;// 个人认证确认成功
	public static final int BIND_USER_SUCCESSED = 19;// 绑定用户成功
	public static final int FIND_STAFF_USER_LIST = 20;// 获取用户列表
	public static final int CREATE_STAFF_QRCODE_SUCCESS = 21;// 重新生成业务员二维码成功
	public static final int GET_USER_DETAIL_INFO_SUCCESSED = 22;// 获取用户详细信息
	public static final int COMMIT_USER_HEAD_SUCCESSED = 23;// 修改头像成功
	public static final int FIND_CHANNEL_USER_LIST = 24;// 查询渠道用户列表
	
	public static final int CHANGE_PWD_SUCCESSED = 27;//修改用户密码成功

	public static final int GET_APPSYS_INFO_UPDATE = 110;// 需要更新
	public static final int GET_APPSYS_INFO_NO_UPDATE = 111;// 不需要更新

	private Handler mHandler;
	private Message mMessage;
	private Context mContext;

	private Map<String, Object> param;
	private String command;

	public UserRequest(Context context, Handler handler) {
		this.mContext = context;
		this.mHandler = handler;
		this.mMessage = mHandler.obtainMessage();
		this.setRequestCompleteListener(this);
	}

	/**
	 * 
	 * login(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param phone
	 * @param password
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void login(String phone, String password) {
		param = new HashMap<String, Object>();
		String loginIp = IpUtils.getWifiIpAddress(mContext);
		if (loginIp == null) {
			loginIp = IpUtils.getLocalIpAddress(mContext);
		}
		if (loginIp == null) {
			loginIp = "null";
		}

		// String loginIpPlace = Client.getCurrentLocation();
		// if (loginIpPlace == null) {
		// loginIpPlace = "null";
		// }
		String loginSerialId = IpUtils.getIMEI(mContext);

		param.put("userpsw", EncryptionUtils.SHA1(password));
		param.put("loginIp", loginIp);
		param.put("loginIpPlace", "null");
		param.put("userphone", phone);
		param.put("loginPlatformTag", "0");
		param.put("loginSerialId", loginSerialId);
		command = LCommands.USER_LOGIN;
		requestByGet(param);
	}

	/**
	 * 员工登录 staffLogin(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param name
	 * @param password
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void channelLogin(String name, String password) {
		param = new HashMap<String, Object>();
		param.put("channelPsw", EncryptionUtils.SHA1(password));
		param.put("channelPhone", name);
		command = LCommands.CHANNEL_LGIN;
		requestByPost(param);
	}

	/**
	 * 检测手机号是否可注册 checkPhone(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param phone
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void checkPhone(String phone) {
		param = new HashMap<String, Object>();
		param.put("phone", phone);
		command = LCommands.CHECK_PHONE + "/" + phone;
		requestByGet(param);
	}

	/**
	 * 获取验证码 getAuthCode(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param phone
	 * @param type
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void getAuthCode(String phone, String type) {
		param = new HashMap<String, Object>();
		String ip = IpUtils.getWifiIpAddress(mContext);
		if (ip == null) {
			ip = IpUtils.getLocalIpAddress(mContext);
		}
		if (ip == null) {
			ip = "null";
		}
		param.put("phone", phone);
		param.put("type", type);
		param.put("ip", ip);
		command = LCommands.GET_AUTH_CODE;
		requestByGet(param);
	}

	/**
	 * 
	 * checkCaptcha(这里用一句话描述这个方法的作用) 检测验证码是否匹配 (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param phone
	 * @param captcha
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void checkCaptcha(String phone, String captcha) {
		param = new HashMap<String, Object>();
		param.put("phone", phone);
		param.put("captcha", captcha);
		command = LCommands.CHECK_GETCAPTCHA;
		requestByGet(param);
	}

	/**
	 * 注册 register(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param type
	 * @param phone
	 * @param userpsw
	 * @param captcha
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void register(String type, String phone, String userpsw,
			String captcha) {
		param = new HashMap<String, Object>();
		param.put("usertype", type);
		param.put("phone", phone);
		param.put("userpsw", EncryptionUtils.SHA1(userpsw));
		param.put("captcha", captcha);
		command = LCommands.REGISTER;
		requestByPost(param);
	}

	/**
	 * 提交企业认证 uploadImage(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param companyname
	 *            公司名稱
	 * @param companyAddr
	 *            公司地址
	 * @param conpanyBussinessNum
	 *            營業執照
	 * @param conmmunicationName
	 *            聯繫人
	 * @param conmmunicationphoneNum
	 *            聯繫電話
	 * @param managerCitizenNum
	 *            身份證號碼
	 * @param fileObjectListJson
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void commitCompanyAuth(String companyname, String companyAddr,
			String conpanyBussinessNum, String conmmunicationName,
			String conmmunicationphoneNum, String managerCitizenNum,
			String cityCode, String fileObjectListJson) {
		param = new HashMap<String, Object>();
		param.put("companyName", companyname);
		param.put("companyAddr", companyAddr);
		param.put("conpanyBussinessNum", conpanyBussinessNum);
		param.put("conmmunicationName", conmmunicationName);
		param.put("conmmunicationphoneNum", conmmunicationphoneNum);
		param.put("managerCitizenNum", managerCitizenNum);
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		param.put("fileObjectListJson", fileObjectListJson);
		param.put("cityCode", cityCode);
		command = LCommands.COMMIT_COMPANY_AUTH_COMMIT;
		requestByPost(param);
	}

	/**
	 * 提交司机个人认证 commitDriverAuth(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param name
	 * @param citizenNum
	 * @param fileObjectListJson
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void commitDriverAuth(String name, String citizenNum,
			String fileObjectListJson) {
		param = new HashMap<String, Object>();
		param.put("name", name);
		param.put("citizenNum", citizenNum);
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		param.put("fileObjectListJson", fileObjectListJson);
		command = LCommands.COMMIT_DRIVER_AUTH_COMMIT;
		requestByPost(param);
	}

	/**
	 * 个人认证 commitOwnnerAuth(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param name
	 * @param citizenNum
	 * @param fileObjectListJson
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void commitOwnnerAuth(String name, String citizenNum,
			String fileObjectListJson) {
		param = new HashMap<String, Object>();
		param.put("name", name);
		param.put("citizenNum", citizenNum);
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		param.put("fileObjectListJson", fileObjectListJson);
		command = LCommands.COMMIT_OWNNER_AUTH_COMMIT;
		requestByPost(param);
	}

	/**
	 * 提交认证 submitAuth(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选) void
	 * 
	 * @exception
	 * @since 1.0.0
	 */
	public void submitAuth(String name, String idPath, String driverPath) {
		param = new HashMap<String, Object>();
		param.put("driverpicpath", driverPath);
		param.put("name", name);
		param.put("citizenpicpath", idPath);
		command = LCommands.SUBMIT_AUTH;
		requestByPost(param);
	}

	/**
	 * 获取企业认证列表 getAuthList(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param validationType认证类型
	 *            0表示全部 1表示未认证 2表示通过认证 3表示认证失败
	 * @param pageNum
	 * @param pageSize
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void getAuthCompanyList(int validationType, int pageNum, int pageSize) {
		param = new HashMap<String, Object>();
		param.put("validationType", validationType);
		param.put("pageNum", pageNum);
		param.put("pageSize", pageSize);
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		command = LCommands.GET_AUTH_COMPANY_LIST;
		requestByGet(param);
	}

	/**
	 * 获取司机认证列表 getAuthDriverList(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param validationType
	 * @param pageNum
	 * @param pageSize
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void getAuthDriverList(int validationType, int pageNum, int pageSize) {
		param = new HashMap<String, Object>();
		param.put("validationType", validationType);
		param.put("pageNum", pageNum);
		param.put("pageSize", pageSize);
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		command = LCommands.GET_AUTH_DRIVER_LIST;
		requestByPost(param);
	}

	/**
	 * 个人认证列表 getAuthOwnnerList(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param validationType
	 * @param pageNum
	 * @param pageSize
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void getAuthOwnnerList(int validationType, int pageNum, int pageSize) {
		param = new HashMap<String, Object>();
		param.put("validationType", validationType);
		param.put("pageNum", pageNum);
		param.put("pageSize", pageSize);
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		command = LCommands.GET_AUTH_OWNNER_LIST;
		requestByGet(param);
	}

	/**
	 * 认证详情 getAuthDetail(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param companyId
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void getAuthCompanyDetail(int companyId) {
		param = new HashMap<String, Object>();
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		param.put("companyId", companyId);
		command = LCommands.GET_AUTH_DETAIL;
		requestByGet(param);
	}

	/**
	 * 司机认证详情 getAuthDriverDetail(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param companyId
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void getAuthDriverDetail(int userId) {
		param = new HashMap<String, Object>();
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		param.put("userId", userId);
		command = LCommands.GET_AUTH_DRIVER_DETAIL;
		requestByGet(param);
	}

	/**
	 * 个人认证详情 getAuthOwnnerDetail(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param userId
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void getAuthOwnnerDetail(int userId) {
		param = new HashMap<String, Object>();
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		param.put("userId", userId);
		command = LCommands.GET_AUTH_OWNNER_DETAIL;
		requestByGet(param);
	}

	/**
	 * 认证 authConfrim(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param companyId
	 * @param verifyStatus
	 *            1为在审核，2为已审核公司，3为审核不通过
	 * @param verifyDescription
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void authConfrim(int companyId, String verifyStatus,
			String verifyDescription) {
		param = new HashMap<String, Object>();
		param.put("companyId", companyId);
		param.put("verifyStatus", verifyStatus);
		param.put("verifyDescription", verifyDescription);
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		command = LCommands.AUTH_CONFIRM;
		requestByGet(param);
	}

	/**
	 * 司机审核 authDriverConfrim(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param companyId
	 * @param verifyStatus
	 * @param verifyDescription
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void authDriverConfrim(int userId, String verifyStatus,
			String verifyDescription) {
		param = new HashMap<String, Object>();
		param.put("userId", userId);
		param.put("verifyStatus", verifyStatus);
		param.put("verifyDescription", verifyDescription);
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		command = LCommands.AUTH_DRIVER_CONFIRM;
		requestByGet(param);
	}

	/**
	 * 
	 * authOwnnerConfrim(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param userId
	 * @param verifyStatus
	 * @param verifyDescription
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void authOwnnerConfrim(int userId, String verifyStatus,
			String verifyDescription) {
		param = new HashMap<String, Object>();
		param.put("userId", userId);
		param.put("verifyStatus", verifyStatus);
		param.put("verifyDescription", verifyDescription);
		// param.put("staffAccessToken", LContext.STAFF_TOKEN);
		command = LCommands.AUTH_OWNNER_CONFIRM;
		requestByGet(param);
	}

	/**
	 * 绑定用户
	 * 
	 * @param phone
	 *            用户手机号
	 */
	public void bindUserConfirm(String phone) {
		param = new HashMap<String, Object>();
		param.put("phone", phone);
		command = LCommands.BIND_USER;

		requestByPost(param);
	}

	/**
	 * 查询是否提交了认证信息
	 * 
	 * @param type
	 * @param startIndex
	 * @param pageSize
	 */
	public void findStaffUserInfoList(int type, int pageNum, int pageSize) {
		param = new HashMap<String, Object>();
		param.put("validationType", type);
		param.put("pageNum", pageNum);
		param.put("pageSize", pageSize);
		command = LCommands.FIND_STAFF_USER_INFO_LIST;
		requestByPost(param);
	}

	/**
	 * 
	 * @param validationType
	 * @param personType
	 *            -1:全部，0：司机，1：货主
	 * @param startTime
	 * @param endTime
	 * @param pageNum
	 * @param pageSize
	 */
	public void findStaffUserInfoList(int validationType, int personType,
			String startTime, String endTime, int pageNum, int pageSize) {
		param = new HashMap<String, Object>();
		param.put("validationType", validationType);
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		param.put("personType", personType);
		param.put("pageNum", pageNum);
		param.put("pageSize", pageSize);
		command = LCommands.FIND_STAFF_USER_INFO_LIST;
		requestByPost(param);
	}
	
	/**
	 * 
	 * @param validationType
	 * @param personType
	 *            -1:全部，0：司机，1：货主
	 * @param startTime
	 * @param endTime
	 * @param pageNum
	 * @param pageSize
	 */
	public void findChannelUserInfoList(int validationType, int personType,
			String startTime, String endTime, int pageNum, int pageSize) {
		param = new HashMap<String, Object>();
		param.put("validationType", validationType);
		param.put("startTime", startTime);
		param.put("endTime", endTime);
//		param.put("personType", personType);
		param.put("pageNum", pageNum);
		param.put("pageSize", pageSize);
		command = LCommands.FIND_CHANNEL_USER_INFO_BY_TIME;
		requestByPost(param);
	}

	/**
	 * 获取用户信息
	 */
	public void getAppSysInfo(String appId, String mobileId) {
		param = new HashMap<String, Object>();
		param.put("appId", appId);
		param.put("mobileId", mobileId);
		param.put("appType", 7);
		command = LCommands.GET_APPSYS_INFO;
		requestByGet(param);
	}

	/**
	 * 重新生成业务员二维码
	 */
	public void reCreateStaffQrCode() {
		param = new HashMap<String, Object>();
		command = LCommands.CREATE_STAFF_QRCODE;

		requestByPost(param);
	}

	/**
	 * 
	 * getUserInfoByToken(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选) void
	 * 
	 * @exception
	 * @since 1.0.0
	 */
	public void getUserInfoByToken() {
		param = new HashMap<String, Object>();
		command = LCommands.GET_USER_INFO;
		requestByGet(param);
	}

	/**
	 * 修改头像 commitUserHead(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
	 * 
	 * @param fileObjectListJson
	 *            void
	 * @exception
	 * @since 1.0.0
	 */
	public void commitUserHead(String fileObjectListJson) {
		param = new HashMap<String, Object>();
		param.put("fileObjectListJson", fileObjectListJson);
		command = LCommands.COMMIT_USER_HEAD;
		requestByPost(param);
	}
	
	/**
	 * change password
	 * @param phone
	 * 			user phone 
	 * @param lastPwd
	 * 			user's old password
	 * @param newPwd
	 * 			new password
	 */
	public void changeUserPassword(String phone, String lastPwd, String newPwd) {
		param = new HashMap<String, Object>();
		param.put("channelPhone", phone);
		param.put("oldChannelPsw", EncryptionUtils.SHA1(lastPwd));
		param.put("channelPsw", EncryptionUtils.SHA1(newPwd));
		command = LCommands.CHANGE_USER_PASSWORD;
		requestByPost(param);
	}

	@Override
	protected void initParams() {
		super.initParams();
		mParam = param;
		mCommand = command;
	}

	@Override
	public void requestSuccessed(HttpResult result) {
		if (command.equals(LCommands.CHANNEL_LGIN)) {
			try {
				JSONObject obj = new JSONObject(result.getResult());
				String accessToken = obj.getString("accessToken");
				mMessage.what = ADMIN_LOGIN_SUCCESSED;
				ChannelInfo channelInfo = JsonUtil.fromJson(obj.getString("user"), ChannelInfo.class);
				channelInfo.accessToken = accessToken;
				mMessage.obj = channelInfo;

			} catch (JSONException e) {
				e.printStackTrace();
			}
		} else if (command.equals(LCommands.USER_LOGIN)) {
			mMessage.what = LOGIN_SUCCESSED;
			UserInfo info = UserParser.parserUserInfo(result.getResult());
			mMessage.obj = info;
		} else if (command.contains(LCommands.CHECK_PHONE)) {
			mMessage.what = CHECK_PHONE_SUCCESSED;
		} else if (command.equals(LCommands.GET_AUTH_CODE)) {
			mMessage.what = GET_AUTH_CODE_SUCCESSED;
		} else if (command.equals(LCommands.CHECK_GETCAPTCHA)) {
			mMessage.what = CHECK_CAPTCHA_SUCCESSED;
		} else if (command.equals(LCommands.REGISTER)) {
			mMessage.what = REGISTER_SUCCESSED;
			mMessage.obj = result.getDescription();
		} else if (command.equals(LCommands.COMMIT_COMPANY_AUTH_COMMIT)) {
			mMessage.what = COMPANY_AUTH_COMMIT_SUCCESSED;
			// mMessage.obj = UserParser.parserUpload(result.getResult());
		} else if (command.equals(LCommands.COMMIT_DRIVER_AUTH_COMMIT)) {
			mMessage.what = DRIVER_AUTH_COMMIT_SUCCESSED;
			// mMessage.obj = UserParser.parserUpload(result.getResult());
		} else if (command.equals(LCommands.COMMIT_OWNNER_AUTH_COMMIT)) {
			mMessage.what = OWNNER_AUTH_COMMIT_SUCCESSED;
			// mMessage.obj = UserParser.parserUpload(result.getResult());
		} else if (command.equals(LCommands.SUBMIT_AUTH)) {
			mMessage.what = SUBMIT_AUTH_SUCCESSED;
			// mMessage.obj = UserParser.parserUpload(result.getResult());
		} else if (command.equals(LCommands.GET_AUTH_COMPANY_LIST)) {
			mMessage.what = GET_AUTH_LIST_SUCCESSED;
			mMessage.obj = UserParser.parserAuthList(result.getResult());
		} else if (command.equals(LCommands.GET_AUTH_DRIVER_LIST)) {
			mMessage.what = GET_AUTH_DRIVER_LIST_SUCCESSED;
			mMessage.obj = UserParser.parserAuthDriverList(result.getResult());
		} else if (command.equals(LCommands.GET_AUTH_OWNNER_LIST)) {
			mMessage.what = GET_AUTH_OWNNER_LIST_SUCCESSED;
			mMessage.obj = UserParser.parserAuthOwnnerList(result.getResult());
		} else if (command.equals(LCommands.GET_AUTH_DETAIL)) {
			mMessage.what = GET_AUTH_DETAIL_SUCCESSED;
			mMessage.obj = UserParser.parserAuthDetailInfo(result.getResult());
		} else if (command.equals(LCommands.GET_AUTH_DRIVER_DETAIL)) {
			mMessage.what = GET_AUTH_DRIVER_DETAIL_SUCCESSED;
			mMessage.obj = UserParser.parserAuthDriverDetailInfo(result
					.getResult());
		} else if (command.equals(LCommands.GET_AUTH_OWNNER_DETAIL)) {
			mMessage.what = GET_AUTH_OWNNER_DETAIL_SUCCESSED;
			mMessage.obj = UserParser.parserAuthOwnnerDetailInfo(result
					.getResult());
		} else if (command.equals(LCommands.AUTH_CONFIRM)) {
			mMessage.what = AUTH_CONFIRM_SUCCESSED;
			mMessage.obj = result.getDescription();
		} else if (command.equals(LCommands.AUTH_DRIVER_CONFIRM)) {
			mMessage.what = AUTH_DRIVER_CONFIRM_SUCCESSED;
			mMessage.obj = result.getDescription();
		} else if (command.equals(LCommands.AUTH_OWNNER_CONFIRM)) {
			mMessage.what = AUTH_OWNNER_CONFIRM_SUCCESSED;
			mMessage.obj = result.getDescription();
		} else if (command.equals(LCommands.BIND_USER)) {
			mMessage.what = BIND_USER_SUCCESSED;
			mMessage.obj = result.getDescription();
		} else if (command.equals(LCommands.GET_APPSYS_INFO)) {
			VersionInfo info = CommonParser
					.parseVersionInfo(result.getResult());
			if (info != null) {
				mMessage.what = GET_APPSYS_INFO_UPDATE;
				mMessage.obj = info;
			} else {
				mMessage.what = GET_APPSYS_INFO_NO_UPDATE;
				mMessage.obj = result.getDescription();
			}
		} else if (command.equals(LCommands.FIND_CHANNEL_USER_INFO_BY_TIME)) {
			String results = result.getResult();
			mMessage.what = FIND_CHANNEL_USER_LIST;
			mMessage.arg1 = result.getNumReturn();
			mMessage.obj = UserParser.parserUserList(results);

		} else if (command.equals(LCommands.GET_USER_INFO)) {
			mMessage.what = GET_USER_DETAIL_INFO_SUCCESSED;
			UserInfo info = UserParser.parserUserDetailInfo(result.getResult());
			mMessage.obj = info;
		} else if (command.equals(LCommands.COMMIT_USER_HEAD)) {
			mMessage.what = COMMIT_USER_HEAD_SUCCESSED;
			// mMessage.obj = UserParser.parserUpload(result.getResult());
		} else if (command.equals(LCommands.CREATE_STAFF_QRCODE)) {
			mMessage.what = CREATE_STAFF_QRCODE_SUCCESS;
			mMessage.obj = result.getResult();
		} else if (command.equals(LCommands.CHANGE_USER_PASSWORD)) {
			mMessage.what = CHANGE_PWD_SUCCESSED;
		}
		mHandler.sendMessage(mMessage);
	}

	@Override
	public void requestFailed(HttpResult result) {
		// 请求失败,result的返回码可判断失败原因，进行如下操作
		mMessage.what = REQUEST_FAILED;
		mMessage.obj = result.getDescription();
		mHandler.sendMessage(mMessage);
	}

}
